package com.study.designmodes.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 网站code枚举
 *
 * @author wyc
 * @since 20210225
 */
@Getter
@AllArgsConstructor
public enum WebsiteCodeEnum {
    /**
     * 默认网厅，实际中不会使用，用于通用的处理
     */
    DEFAULT("DEFAULT", "默认", HrssAreaCodeEnum.UNKNOWN, null),

    /**
     * 默认网厅，新逻辑的通用处理
     */
    DEFAULTV2("DEFAULTV2", "默认V2", HrssAreaCodeEnum.UNKNOWN, null),

    /**
     * 深圳社保网厅
     */
    SHENZHEN_SOCINS("SHENZHEN_SOCINS", "深圳社保网厅", HrssAreaCodeEnum.SHEN_ZHEN, InsuranceCategoryEnum.SOCINS),

    /**
     * 上海社保网厅
     */
    SHANGHAI_SOCINS("SHANGHAI_SOCINS", "上海社保网厅", HrssAreaCodeEnum.SHANG_HAI, InsuranceCategoryEnum.SOCINS),

    /**
     * 山西社保网厅
     */
    SHANXI_SOCINS("SHANXI_SOCINS", "山西社保网厅", HrssAreaCodeEnum.SHAN_XI, InsuranceCategoryEnum.SOCINS),

    /**
     * 广东社保网厅
     */
    GUANGDONG_SOCINS("GUANGDONG_SOCINS", "广东社保网厅", HrssAreaCodeEnum.GUANG_DONG, InsuranceCategoryEnum.SOCINS),

    /**
     * 北京社保网厅
     */
    BEIJING_SOCINS("BEIJING_SOCINS", "北京社保网厅", HrssAreaCodeEnum.BEI_JING, InsuranceCategoryEnum.SOCINS),

    /**
     * 北京医保网厅
     */
    BEIJING_MEDICAL("BEIJING_MEDICAL", "北京医保网厅", HrssAreaCodeEnum.BEI_JING, InsuranceCategoryEnum.MEDICAL),

    /**
     * 厦门社保网厅
     */
    XIAMEN_SOCINS("XIAMEN_SOCINS", "厦门社保网厅", HrssAreaCodeEnum.XIA_MEN, InsuranceCategoryEnum.SOCINS),

    /**
     * 厦门电子税务局
     */
    XIAMEN_TAX("XIAMEN_TAX", "厦门电子税务局", HrssAreaCodeEnum.XIA_MEN, InsuranceCategoryEnum.SOCINS),

    /**
     * 浙江政务服务平台
     */
    ZHEJIANG_SOCINS("ZHEJIANG_SOCINS", "浙江政务服务平台", HrssAreaCodeEnum.ZHE_JIANG, InsuranceCategoryEnum.SOCINS),

    /**
     * 四川社保网厅
     */
    SICHUAN_SOCINS("SICHUAN_SOCINS", "四川社保网厅", HrssAreaCodeEnum.SI_CHUAN, InsuranceCategoryEnum.SOCINS),
    /**
     * 河北医保网厅
     */
    HEBEI_MEDICAL("HEBEI_MEDICAL", "河北医保网厅", HrssAreaCodeEnum.HE_BEI, InsuranceCategoryEnum.MEDICAL),

    /**
     * 新疆社保网厅
     */
    XINJIANG_SOCINS("XINJIANG_SOCINS", "新疆社保网厅", HrssAreaCodeEnum.XIN_JIANG, InsuranceCategoryEnum.SOCINS),

    /**
     * 新疆医保网厅
     */
    XINJIANG_MEDICAL("XINJIANG_MEDICAL", "新疆医保网厅", HrssAreaCodeEnum.XIN_JIANG, InsuranceCategoryEnum.MEDICAL),

    /**
     * 福建省社保网厅
     */
    FUJIAN_SOCINS("FUJIAN_SOCINS", "福建省社保网厅", HrssAreaCodeEnum.FU_JIAN, InsuranceCategoryEnum.SOCINS),

    /**
     * 山西医保网厅
     */
    SHANXI_MEDICAL("SHANXI_MEDICAL", "山西医保网厅", HrssAreaCodeEnum.SHAN_XI, InsuranceCategoryEnum.MEDICAL),

    /**
     * 四川医保网厅
     */
    SICHUAN_MEDICAL("SICHUAN_MEDICAL", "四川医保网厅", HrssAreaCodeEnum.SI_CHUAN, InsuranceCategoryEnum.MEDICAL),

    /**
     * 江苏社保网厅
     */
    JIANGSU_SOCINS("JIANGSU_SOCINS", "江苏社保网厅", HrssAreaCodeEnum.JIANG_SU, InsuranceCategoryEnum.SOCINS),
    ;

    /**
     * code
     */
    private final String code;

    /**
     * desc
     */
    private final String desc;

    /**
     * areacode
     */
    private final HrssAreaCodeEnum areaCodeEnum;

    /**
     * 险种类型
     */
    private final InsuranceCategoryEnum insuranceCategoryEnum;

    public static WebsiteCodeEnum getByCode(String code) {
        for (WebsiteCodeEnum obj : WebsiteCodeEnum.values()) {
            if (Objects.equals(obj.code, code)) {
                return obj;
            }
        }
        return null;
    }

    public static WebsiteCodeEnum getByDesc(String desc) {
        for (WebsiteCodeEnum obj : WebsiteCodeEnum.values()) {
            if (Objects.equals(obj.desc, desc)) {
                return obj;
            }
        }
        return null;
    }

    /**
     * 根据地区代码和险种类别获取网厅代码
     *
     * @param areaCodeEnum          地区代码
     * @param insuranceCategoryEnum 险种类型
     * @return 网厅代码
     */
    public static WebsiteCodeEnum getByAreaCodeAndInsuranceCategory(HrssAreaCodeEnum areaCodeEnum, InsuranceCategoryEnum insuranceCategoryEnum) {
        for (WebsiteCodeEnum value : WebsiteCodeEnum.values()) {
            if (value.getAreaCodeEnum() == areaCodeEnum && value.getInsuranceCategoryEnum() == insuranceCategoryEnum) {
                return value;
            }
        }
        return null;
    }
}
